<?php
namespace Admin\Controller;
use Think\Controller;
class InstallController extends Controller
{
	public function index()
	{
		$this->display();
	}
	public function check()
	{
		$this->display();
	}
	public function mysql()
	{
		$this->display();
	}
	public function resbackup()
	{
		if($_POST['put']!='')
		{
			$show = '';
			$host = trim($_POST['host']);
			$name = trim($_POST['name']);
			$user = trim($_POST['user']);
			$pwd = trim($_POST['pwd']);
			$prefix = trim($_POST['prefix']);

			$data = array();
			$data['webname'] = trim($_POST['webname']);
			$data['hostname'] = trim($_POST['hostname']);
			$data['mail'] = trim($_POST['mail']);
			$data['adminuser'] = trim($_POST['adminuser']);
		    $data['adminpwd'] = trim($_POST['adminpwd']);

		    $config='';

		    $dbconfig = array();
		    $dbconfig['DB_TYPE'] ='mysql';
			$dbconfig['DB_HOST'] = trim($_POST['host']);
			$dbconfig['DB_NAME'] = trim($_POST['name']);
			$dbconfig['DB_USER'] = trim($_POST['user']);
		    $dbconfig['DB_PWD'] = trim($_POST['pwd']);
		    $dbconfig['DB_PORT'] = '3306';
		    $dbconfig['DB_PREFIX'] = trim($_POST['prefix']);

		    $config .=' <?php  return ';
		    $config .= var_export($dbconfig,true);
		    $config .='  ;';

		    $filename = ".".C("CONFIG_DEV");
		   
		   
		    if(file_put_contents($filename, $config))
		    {

		    	$this->success("安装成功！请稍后，即将跳转主页",'../Baksql/index',5);
		    }
		    else
		    {
		    	$this->error("安装网站操作失败！",'./',3);
		    }
	    } 
		$this->display();
	}
}